import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== $Lazy
const Page 		= $Lazy.load(()=>import('#tp/page/page-container'))
const $cache 	= $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '合同编号',		name: 'contract_code' },
			{ label: '合同名称',		name: 'contract_name' },
			{ label: '操作人',		name: 'operator_id',	type:'select',		loading:true},
			{ label: '操作时间',		names: ['start_date','end_date'],	type:'date-range', 	loading:true },
		],
	}
	componentDidMount(){
		this.getSelect()
		if(window.isInit){
			this.fetch()
		}
	}
	
	// paging
	fetch = () => $fn.fetch.call(this,'bs-contract-log/index')
	
	// 获取下拉数据
	getSelect = () => {
		const { forms } = this.state
		$cache.then( async f => {
			// 操作人
			$fn.setRow( forms, 'operator_id', await f.getCache({ api:'employee' }) )
			this.setState({ forms })
		})
	}
	
	// 表单
	cols = [
		{ title: '合同编号', 		dataIndex: 'contract_code', 		...$fn.table.spec_code },
		{ title: '合同名称', 		dataIndex: 'contract_name', 		width:150 },
		{ title: '创建人', 			dataIndex: 'operator_name', 		...$fn.table.name	 },
		{ title: '操作类型', 		dataIndex: 'operator_type',  		width:150 },
		{ title: '操作时间', 		dataIndex: 'operator_at',  			...$fn.table.time},
		{ title: '描述', 			dataIndex: 'operator_remark', 		width:180 }
	]
	
	render(){
		return (
			<Page title='合同操作记录'>
				{/* 搜索 */}
				{ SearchForm.call(this) }
				{/* 表格 */}
				{ Table.call(this, {isInit: window.isInit}) }
			</Page>
		)
	}
}

export default Index
 // 新增合同操作记录页面 2022-4-21 --马婷 